﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Data.OleDb;
using System.IO;

namespace DiaryPlanner
{
    public partial class AlbumAddFolder : Form
    {
       public  Album thisAlbumObject;

        public AlbumAddFolder(Album ab)
        {
            thisAlbumObject = ab;
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)//취소
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)//폴더 추가
        {
            if (folderName.Text == "" || folderName.Text == " " || folderName.Text == "  " || folderName.Text == "   " || folderName.Text == "    ")
            {            
                return;
            }
           
            //폴더 추가

            AlbumFolder af = new AlbumFolder(thisAlbumObject);//보여지는 폴더 이름
            af.realName = "AF" + "_" + System.DateTime.Now.Year.ToString() + "_" +
                System.DateTime.Now.Month.ToString() + "_" +
                System.DateTime.Now.Day.ToString() + "_" +
                    System.DateTime.Now.Hour.ToString() + "_" +
                    System.DateTime.Now.Minute.ToString() + "_" +
                    System.DateTime.Now.Second.ToString();//진짜 폴더 이름
           
            //디렉토리에 폴더 추가
            try
            {
                // If the directory doesn't exist, create it.
                if (!Directory.Exists("./Album/"+af.realName))
                {
                    Directory.CreateDirectory("./Album/" + af.realName);
                }
            }
            catch (Exception)
            {
                // Fail silently
            }


            af.folderName = this.folderName.Text.ToString();
            thisAlbumObject.FolderList.Add(af);// folderList에 폴더 추가            
            thisAlbumObject.nowFolder = af;//nowfolder
            thisAlbumObject.viewAllFolder();
            thisAlbumObject.viewAllPhoto();//nowFolder의 내용

            this.Close();
        }
    }
}
